﻿<Divider Text="双向绑定显示标签" Alignment="Alignment.Left" style="margin: 2rem 0;"></Divider>
<ValidateForm class="form-inline" Model="@Model">
    <div class="row">
        <div class="form-group col-12">
            <Select Color="Color.Primary" Items="@Items" @bind-Value="@Model.Name" ShowLabel="true"></Select>
        </div>
    </div>
</ValidateForm>
<Divider Text="双向绑定不显示标签" Alignment="Alignment.Left" style="margin: 2rem 0;"></Divider>
<div class="form-inline">
    <div class="row">
        <div class="form-group col-12">
            <Select Color="Color.Primary" Items="@Items" @bind-Value="@Model.Name" ShowLabel="false"></Select>
        </div>
    </div>
</div>
<Divider Text="自定义 DisplayText" Alignment="Alignment.Left" style="margin: 2rem 0;"></Divider>
<div class="form-inline">
    <div class="row">
        <div class="form-group col-12">
            <Select Color="Color.Primary" Items="@Items" @bind-Value="@Model.Name" DisplayText="自定义城市" ShowLabel="true"></Select>
        </div>
    </div>
</div>

@code {
    /// <summary>
    /// 
    /// </summary>
    private Foo Model { get; set; } = new Foo();

    /// <summary>
    /// 获得 默认数据集合
    /// </summary>
    private readonly IEnumerable<SelectedItem> Items = new SelectedItem[]
    {
        new SelectedItem ("Beijing", "北京"),
        new SelectedItem ("Shanghai", "上海") { Active = true }
    };

    internal class Foo
    {
        /// <summary>
        /// 
        /// </summary>
        [DisplayName("城市名称")]
        public string Name { get; set; } = "Shanghai";
    }
}
